package com.bolun998300.personal_blog_springboot.service;

import com.bolun998300.personal_blog_springboot.dao.MenuDao;
import com.bolun998300.personal_blog_springboot.pojo.Menu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MenuService {

    @Autowired
    private MenuDao menuDao;

    public List<Menu> list(){
        List<Menu> menuParentList =  menuDao.findByMenuIsParentOrderById(true);

        for(Menu m : menuParentList){
            List<Menu> menuChildList = null;
                menuChildList = menuDao.findByMenuParentIdOrderById(m.getId());
            m.setMenuList(menuChildList);
        }

        return menuParentList;
    }



}
